﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bovril.PlayingCards.French
{
    public class Deck
    {
        public Deck()
        {
            cards_ = new List<Card>(52);
            for(int suit = SuitValue.MinValue ; suit <= SuitValue.MaxValue ; ++suit)
            {
                for (int rank = RankValue.MinValue; rank <= RankValue.MaxValue; ++rank)
                {
                    cards_.Add(new Card(rank, suit));
                }
            }
        }

        public void Shuffle()
        {
            List<Card> shuffledCards = new List<Card>(cards_.Count);
            while (cards_.Count > 0)
            {
                int cardIndex = random_.Next(0, cards_.Count);
                shuffledCards.Add(cards_[cardIndex]);
                cards_.RemoveAt(cardIndex);
            }

            cards_ = shuffledCards;
        }

        private List<Card> cards_;
        private static Random random_ = new Random();
    }
}
